function intSwiper(){
  window.bannerSwiper=new Swiper('.swiper-container', {
    autoplay : 3000,
    spaceBetween: 30,
    effect: 'fade',
    pagination: '.swiper-pagination',
    paginationClickable :true,
    paginationBulletRender: function (swiper, index, className) {
        return '<span class="' + className + '" data-index="'+index+'"></span>';
    },
    onInit: function(swiper){
      $(".swiper-container").on("mouseenter",".swiper-pagination-bullet",function(){
        window.bannerSwiper.slideTo(this.getAttribute("data-index"))
      })
    }
  });
}
function getProjectBanner(){
  fetchApi({
    type:"GET",
    apiKey:'GET_PROJECT_BANNER',
    successCb:function(data){
      var str = ''
      for(var i =0,l=data.length;i<l;i++){
        str+='<div class="swiper-slide" style="background:url('+host+data[i].informationPageImage+') center center no-repeat"></div>'
      }
      $("#projectBanner").html(str)
      intSwiper()
    }
  })
}
function getCasesList(){
  $.ajax({
    type: 'POST',
    url: ajaxUrlObj['GET_CASES_LIST'],
    data: {page:1,rows:1000},
    success: function(rep){
      if (typeof rep === 'string') {
        rep = JSON.parse(rep)
      }
      if (rep.code == 1){
        var data = typeof rep.data === 'string' ? JSON.parse(rep.data).rows :rep.data.rows
        var str = ''
        for(var i =0,l=data.length;i<l;i++){
          str+='<li> <span class="blueBg"></span>'+
                '  <div class="item">'+
                '    <p class="img"> <img src="'+host+data[i].firstCaseImage+'"><span class="black"></span><span class="ntype">案例赏析</span></p>'+
                '    <p class="t">'+data[i].caseName+'</p>'+
                '    <p class="bot clearfix"><span class="ntime">'+data[i].createtime+'</span></p>'+
                '    <a href="project_details.html?id='+data[i].id+'" class="linkA"></a> </div>'+
                '</li>'
        }
        $("#div_news").html(str)
      }
    },
    error: function(error){
      console.log(error)
    }
  });
}
$(window).ready(function(){
  getProjectBanner()
  getCasesList()
})